package view.drawing;

import map.Direction;
import entity.Entity;

public class EntityIdleState extends State<Entity> {
	
//	private static final String IDLE_N = "idle_n";
//	private static final String IDLE_NW = "idle_nw";
//	private static final String IDLE_NE = "idle_ne";
//	private static final String IDLE_S = "idle_s";
//	private static final String IDLE_SE = "idle_se";
//	private static final String IDLE_SW = "idle_sw";
	
	private static final String IDLE_BASE = "idle";
	
	private String mCurrentStateString;
	
	public EntityIdleState() {
		// Default state is IDLE_N until the first update
		mCurrentStateString = createStringFromDirection(Direction.NORTH);
	}

	@Override
	public void update(long elapsedTime, Entity model, DrawState<Entity> drawState) {
		
		Direction dir = model.getDirection();
		
		if (dir == null) dir = Direction.NORTH;
		
		// new string is
		String newState = createStringFromDirection(dir);
		
		if (! newState.equals(mCurrentStateString)) {
			// update necessary
			//System.out.format("EntityIdleState::update() > Entity '%s' changed state from %s to %s\n", model.getName(), mCurrentStateString, newState);
			mCurrentStateString = newState;
		}
		
		
		
	}
	
	private String createStringFromDirection(Direction dir) {
		return (String.format("%s_%s", IDLE_BASE, dir.toString()));
	}

	@Override
	public String getStateString() {
		return (mCurrentStateString);
	}

}
